1. /* scfacosh.cpp by K.Tsuru */
  2. // function ID = 9118 since ver 2.18
  3. // bug fix version 2.21
  4. /*****************************************
  5. SComplex class
  6. It returns arcosh(z).
  7. Cacosh(z) = Clog{z + Csqrt(z+1)*Csqrt(z-1)}.
  8. ={ i arccos(z) Im(z)>0
  9. { (-i)arccos(z) Im(z)<0
  10. Gradshteyn and Ryzhik (2000, p. xxx)
  11. [reference]WolframMathWorld's page
  12. Calculus and Analysis > Special Functions > Hyperbolic Functions >
  13. Interactive Entries > webMathematica Examples >
  14. Inverse Hyperbolic Cosine
  15. ver 2.21
  16. When z = x(pure real),let acosh(x) = p,
  17. x = cosh(p) >= 1 must be satisfied.
  18. *****************************************/
  19. #ifndef SN_H
  20. #include "sn.h"
  21. #endif
  22. #if 0
  23. SComplex Cacosh(const SComplex& z) {
  24. // SComplex y = Csqrt(z * z - ONE); cannot be used.
  25. if(z == 0.0) return SComplex(0.0, MPi2()); // log(i) = i*pi/2
  26. if(Im(z) == 0.0){ // pure real z = x
  27. if(Re(z) <= 1.0) z.Real().SetError(z.Real().DOMAIN_ERR, "Cacosh(z) with z = x(x < 1.0))", 9118);
  28. return SComplex(Acosh(Re(z)), 0.0); // arcosh(x)
  29. }
  30. SComplex y = Csqrt(z + ONE) * Csqrt(z - ONE);
  31. return Clog(z + y);
  32. }
  33. #else /********************************/
  34. SComplex Cacosh(const SComplex& z) {
  35. if(z == 0.0) return SComplex(0.0, MPi2()); // log(i) = i*pi/2
  36. if(Im(z) == 0.0){ // pure real z = x
  37. if(Re(z) <= 1.0) z.Real().SetError(z.Real().DOMAIN_ERR, "Cacosh(z) with z = x(x < 1.0))", 9116);
  38. return SComplex(Acosh(Re(z)), 0.0); // arcosh(x)
  39. }
  40. //if(z == 0.0) return Clog(I);
  41. if(Im(z) > 0.0) return IU * Cacos(z);// i*arccos(z) in the upper half of the complex plane
  42. return MI * Cacos(z); // -i*arccos(z)
  43. }
  44. #endif

scfacosh.cpp : last modifiled at 2015/10/23 15:42:32(1,632 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:08 (Fri Oct 06 15:27:08 2017).